from django.db import models


# Create your models here.
class Explain(models.Model):
    word = models.TextField(verbose_name="释义")

    class Meta:
        db_table = "explain"
        verbose_name = '释义表'
        verbose_name_plural = verbose_name
        app_label = "book1"


class Describe(models.Model):
    pinyin = models.CharField(max_length=50, verbose_name="拼音", null=True, blank=True)
    strokes = models.IntegerField(verbose_name="笔画", null=True, blank=True)

    class Meta:
        db_table = "describe"
        verbose_name = '描述表'
        verbose_name_plural = verbose_name
        app_label = "book1"


class ImageData(models.Model):
    name = models.TextField(verbose_name="名称")
    save_id = models.TextField(verbose_name="图片链接",blank=True,null=True)
    parent = models.ForeignKey('self', verbose_name='上一级', null=True, blank=True, on_delete=models.SET_NULL)

    class Meta:
        db_table = "imagedata"
        verbose_name = '图片表'
        verbose_name_plural = verbose_name
        app_label = "book1"


class Word(models.Model):
    word = models.CharField(max_length=50, verbose_name="词名")
    file_label = models.CharField(max_length=100, verbose_name="书名/卷数")
    Similar_character = models.TextField(verbose_name="异体字", blank=True, null=True)
    word_explain = models.ForeignKey(Explain, verbose_name="释义", on_delete=models.CASCADE, related_name="word_describe")
    otherInfo = models.ForeignKey(Describe, on_delete=models.CASCADE)

    class Meta:
        db_table = "word"
        verbose_name = '词表'
        verbose_name_plural = verbose_name
        app_label = "book1"
